const fs = require('fs'),
    request = require('request'),
    wechatApi = require('../config/config').wechatApi,
    menus = require('../config/config').menus,
    commonAccessToken = fs.readFileSync('./config/commonAccessToken').toString();


function createMenu() {
    let options = {
        url: wechatApi.buildMenusApiPrefix + commonAccessToken,
        form: JSON.stringify(menus),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    };

    request.post(options, function (err, res, body) {
        if (err) {
            console.log(11111111111,err)
        }else {
            console.log(body);
        }
    })

}

module.exports = createMenu;